package com.amethyst.mybatisplus.join.entity;

import com.amethyst.mybatisplus.join.enums.Sex;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.yulichang.annotation.MPJMapping;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @author Amethyst
 * @date 2021/8/25
 */
@Data
@Accessors(chain = true)
@TableName("user_deep")
public class UserDeep {
    @TableId
    private Integer id;
    private Integer pid;
    private String name;
    private Sex sex;
    private String headImg;
    @TableLogic
    private Boolean del;

    /**
     * 查询上级，一对一
     */
    @TableField(exist = false)
    @MPJMapping(tag = UserDeep.class, thisField = "pid", joinField = "id")
    private UserDeep pUser;

    /**
     * 查询下级，一对多
     */
    @TableField(exist = false)
    @MPJMapping(tag = UserDeep.class, thisField = "id", joinField = "pid")
    private List<UserDeep> childUser;
}
